<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css">
    <title>设备巡检记录表</title>
    <style type="text/css">
        .left-label {
            width: 100px !important
        }
        .icon-style {
            line-height: 39px !important
        }
    </style>
    <link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
    <link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
    <script type="text/html" id="toolbar">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-blue" lay-event="add"><i class="layui-icon layui-icon-add-1">新增</i></button>
            <button class="layui-btn layui-btn-blue" lay-event="delete"><i class="layui-icon layui-icon-delete">批量删除</i></button>
        </div>
    </script>

    <script type="text/html" id="rowToolbar">
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
    <script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>
</head>
<body class="layui-view-body">
<input type="hidden" id="preRowId" name="preRowId">
<div id="dv01" class="demoTable" style="padding:10px 0 0 15px">
    <div id="dv02" class="layui-inline">
        <%--
        	<input class="layui-input" name="searchTime" id="searchTime" placeholder="请输入时间检索" style="display: inline; width: 45%">
        --%>
        <input class="layui-input" name="keyword" id="keyword" placeholder="请输入设备名称" autocomplete="off" style="display: inline; width: 100%">
    </div>
    <button class="layui-btn layui-btn-blue" style="margin: 0 0 0 10px" data-type="reload"><i class="layui-icon layui-icon-search">搜索</i></button>
</div>
<table class="layui-hide" id="tableList" lay-filter="tableList"></table>
<p>
    <br/>
</p>
<script src="${pageContext.request.contextPath }/assets/layui.all.js"></script>
<script type="text/javascript">
    layui.use(['table','layer','upload','form','laydate'], function(){
        var laydate = layui.laydate;
        var form = layui.form;
        var table = layui.table;

        var $ = layui.jquery, active = {
            reload:function () {
                //var searchTime = $("#searchTime").val();
                var keyword01 = $("#keyword").val();
                //console.log(searchTime + ',' + keyword);
                table.reload('contenttable',{
                    method:'get',
                    where:{"keyword01":keyword01}
                });
            }
        }
        $('.layui-btn').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        table.render({
            elem: '#tableList'
            ,url:'${pageContext.request.contextPath }/deviceAlarm/queryCheckRecord.do'
            //,toolbar: '#toolbar'
            ,title: '设备信息'
            ,id :'contenttable'
            ,limits:[10,20,30]
            ,cols: [[
                {type: 'checkbox', fixed: 'left', },
                {field:'id', title:'ID', sort: true, type:'numbers'},
                {field:'deviceNo', title:'设备编号'},
                {field:'deviceName', title:'设备名称'},
                {field:'deviceVersion', title:'规格型号'},
                {field:'useDept', title:'使用部门'},
                {field:'useLocation', title:'使用地点'},
                {field:'checkMan', title:'巡检人'},
                {field:'submitTime', title:'巡检时间'},
                {field:'remark01', title:'维护维修记录内容'},
                {field:'remark02', title:'设备巡检具体项和内容', templet:function (rowData){
                    return "<a href='javascript:void(0)' style='color:#4D61B3' onclick='checkItemNameDetail2(\""+rowData.id+"\")'>"+'巡检项详细'+"</a>";
                }},
                //{unresize: true, title:'操作', toolbar: '#rowToolbar'}
            ]],
            page: true
        });

        //头工具栏事件
        table.on('toolbar(tableList)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){
                //新增
                case 'add':
                    layer.open({
                        type: 1 					//Page层类型
                        ,area: ['40%', '70%'] 	//宽  高
                        ,title: '新增'
                        ,shade: 0.6 				//遮罩透明度
                        ,maxmin: true 				//允许全屏最小化
                        ,anim: 1 					//0-6的动画形式，-1不开启
                        //,content: $("#addFormID")
                        ,content: '<form class="layui-form" id="addFormID">'+
                        '<table>'+
                    		'<tr>'+    
                    			'<td><label class="layui-form-label left-label" style="margin-top: 20px">设备编号</label></td>'+
                    			'<td>'+
	                        		'<div class="layui-input-block" style="width: 150px; margin-left: 0px; margin-top:20px">'+
					           			'<select class="layui-select" id="deviceNo" name="deviceNo" lay-filter="displayInfo" lay-verify="deviceNo">'+
					                   		'<option value="">请选择</option>'+
					                   	'</select>'+
				                	'</div>'+
                    			'</td>'+
                            	'<td><label class="layui-form-label left-label" style="margin-top: 20px">规格型号</label></td>'+
                            	'<td><input type="text" id="deviceVersion" name="deviceVersion" autocomplete="off" class="layui-input" style="width:150px; margin-top: 20px"></td>'+
                            '<tr>'+
                            '<tr style="height:20px"></tr>'+
                            '<tr>'+    
                            	'<td><label class="layui-form-label left-label">设备名称</label></td>'+
                    			'<td><input type="text" id="deviceName" name="deviceName" lay-verify="deviceName" autocomplete="off" class="layui-input" style="width:150px"></td>'+
                        		'<td><label class="layui-form-label left-label">使用部门</label></td>'+
                        		'<td>'+ 
	                        		'<div class="layui-input-block" style="width: 150px; margin-left: 0px;">'+
	                            		'<select class="layui-select" id="useDept" name="useDept" lay-verify="required">'+
	                            			'<option value="">请选择</option>'+
	                            		'</select>'+
	                            	'</div>'+
                            	'</td>'+
                        	'<tr>'+
                        	'<tr style="height:20px"></tr>'+
                        	'<tr>'+    
	                    		'<td><label class="layui-form-label left-label">使用地点</label></td>'+
	                    		'<td><input type="text" name="useLocation" id="useLocation" autocomplete="off" class="layui-input" style="width:150px"></td>'+
	                        	'<td><label class="layui-form-label left-label">设备巡检</label></td>'+
	                        	'<td><input type="button" value="具体项和内容" class="layui-input" style="width:150px" onclick="javascript:lookupItem01()"></td>'+
                        	'<tr>'+
                        	'<tr style="height:20px"></tr>'+
                        	'<tr>'+    
	                    		'<td><input type="hidden" id="checkItemDetailIDArr" name="checkItemDetailIDArr"></td>'+
                    		'<tr>'+
                    		'<tr style="height:20px"></tr>'+
                    		'<tr>'+    
                    			'<td><label class="layui-form-label left-label">巡检人</label></td>'+
                    			'<td><input type="text" name="checkMan" id="checkMan" autocomplete="off" class="layui-input" style="width:150px"></td>'+
                        		'<td><label class="layui-form-label left-label">巡检时间</label></td>'+
                        		'<td><input type="text" name="submitTime" id="submitTime1" autocomplete="off" class="layui-input" style="width:150px"></td>'+
                    		'<tr>'+
                    		'<tr style="height:20px"></tr>'+
                    		'<tr>'+    
                    			'<td><label class="layui-form-label left-label">维修维护记录内容</label></td>'+
                    			'<td><textarea type="text" name="remark01" id="remark01" autocomplete="off" class="layui-textarea" style="width:150px;"></textarea></td>'+
                    			'<td></td>'+
                    			'<td></td>'+
                    		'<tr>'+
                    		'<tr style="height:20px"></tr>'+
                    		'<tr align="center">'+    
                				'<td colspan="2"><button class="layui-btn layui-btn-blue" lay-submit lay-filter="addForm" style="margin-left:160px; margin-bottom: 20px">立即提交</button></td>'+
                				'<td colspan="2">&emsp;&emsp;&emsp;&emsp;<button type="reset" class="layui-btn layui-btn-primary" style="margin-bottom: 20px">重置</button></td>'+
                			'<tr>'+
                          '</table>'+
                        '</form>'
                        ,success: function(){
                            //巡检时间
                            laydate.render({
                                elem: '#submitTime1',
                                type: 'datetime'
                            });
                          	//下拉查找所有设备
                            $.ajax({
        		  	            type: 'POST',
        		  	            url: '${pageContext.request.contextPath}/device/queryAllDeviceList.do',
        		  	            dataType: 'json',
        		  	            async: false,
        		  	            success: function (data){
        		  	                for (var i = 0; i < data.length; i++) {
        		  	                    $("#deviceNo").append("<option value='"+ data[i].deviceNo +"'>"+ data[i].deviceNo +"</option>");
        		  	                }
        		  	            }
        		  	        });
                          	//下拉框查找所有部门
        					$.ajax({
        			            type: 'POST',
        			            url: '${pageContext.request.contextPath}/device/queryAllDeptList.do',
        			            dataType: 'json',
        			            async: false,
        			            success: function (data){
        			                for (var i = 0; i < data.length; i++) {
        			                    $("#useDept").append("<option value='"+ data[i].name +"'>"+ data[i].name +"</option>");
        			                }
        			            }
        			        });
                            //初始化radio、select等元素
                            form.render();
                        }
                    });
                    break;
                //批量删除
                case 'delete':
                    var data = checkStatus.data;
                    var idArr = new Array();
                    if(data.length == 0){
                        toastr.warning("请至少选择一条记录！");
                    }
                    for(var i=0;i < data.length;i++){
                        /*alert(data[i].id)*/
                        idArr[i] = data[i].id;
                    }
                    $.ajax({
                        type:'post',
                        url:'${pageContext.request.contextPath }/deviceAlarm/deleteCheckRecordById.do',
                        data:{"idArr" : idArr},
                        success:function(data){
                            layer.confirm('确定删除吗？', function(index){
                                if(data > 0){
                                    toastr.success("删除成功！");
                                    location.reload();
                                    /*setTimeout(function(){
                                        //使用setTimeout（）方法设定定时2000毫秒
                                        //关闭模态框
                                        //父页面刷新
                                        window.location.reload();
                                    },2000);*/
                                }else{
                                    toastr.warning("删除失败！");
                                    location.reload();
                                }
                            });
                        }
                    });
                    break;
                case 'select':
                    /*console.log(obj)*/
                    break;
            };
        });

        //监听行工具事件
        table.on('tool(tableList)', function(obj){
            var data = obj.data;
            var idArr = new Array();
            //单个删除
            if(obj.event === 'del'){
                layer.confirm('确定删除吗？', function(index){
                    var id = obj.data.id;
                    idArr[0] = id;
                    $.ajax({
                        type:'post',
                        url:'${pageContext.request.contextPath }/deviceAlarm/deleteCheckRecordById.do',
                        data:{ "idArr" : idArr },
                        success:function(data){
                            if(data > 0){
                                toastrStyle();
                                toastr.success("删除成功！");
                                setTimeout(function(){
                                    location.reload();
                                },1000);
                                /*setTimeout(function(){
                                    //关闭模态框
                                    //父页面刷新
                                    window.location.reload();
                                },2000);*/
                            }else{
                                toastrStyle();
                                toastr.warning("删除失败！");
                                setTimeout(function(){
                                    location.reload();
                                },1000);
                            }
                        }
                    });
                    layer.close(index);
                });
            } else if(obj.event === 'edit'){
                layer.open({
                    type: 1 							//Page层类型
                    ,area: ['40%', '70%']				//宽  高
                    ,title: '编辑'
                    ,shade: 0.6 						//遮罩透明度
                    ,maxmin: true 					    //允许全屏最小化
                    ,anim: 1 							//0-6的动画形式，-1不开启
                    ,content: '<form class="layui-form" id="editFormID">'+
	                '<table>'+
	            		'<tr>'+
	            			'<td><input class="layui-hide" id="id" name="id" value="'+data.id+'"></td>'+
	                    '<tr>'+
	                    '<tr>'+    
	                		'<td><label class="layui-form-label left-label" style="margin-top: 20px">设备名称</label></td>'+
	                		'<td>'+
	                    		'<div class="layui-input-block" style="width: 150px; margin-left: 0px; margin-top:20px">'+
				           			'<select class="layui-select" id="deviceNo" name="deviceNo" lay-filter="displayInfo" lay-verify="deviceNo">'+
				                   		'<option value="">请选择</option>'+
				                   	'</select>'+
			                	'</div>'+
            				'</td>'+
	                    	'<td><label class="layui-form-label left-label" style="margin-top: 20px">规格型号</label></td>'+
	                    	'<td><input type="text" id="deviceVersion" name="deviceVersion" value="'+data.deviceVersion+'" autocomplete="off" class="layui-input" style="width:150px; margin-top: 20px"></td>'+
	                    '<tr>'+
	                    '<tr style="height:20px"></tr>'+
	                    '<tr>'+    
	            			'<td><label class="layui-form-label left-label">设备名称</label></td>'+
	            			'<td><input type="text" id="deviceName" name="deviceName" value="'+data.deviceName+'" autocomplete="off" class="layui-input" style="width:150px"></td>'+
	            			/* '<td><input type="text" name="deviceNo" lay-verify="required" value="'+data.deviceNo+'" autocomplete="off" class="layui-input" style="width:150px"></td>'+ */
	                		'<td><label class="layui-form-label left-label">使用部门</label></td>'+
	                		'<td>'+ 
	                    		'<div class="layui-input-block" style="width: 150px; margin-left: 0px;">'+
	                        		'<select class="layui-select" id="useDept" name="useDept" lay-verify="required">'+
	                        			'<option value="">请选择</option>'+
	                        		'</select>'+
	                        	'</div>'+
	                    	'</td>'+
	                	'<tr>'+
	                	'<tr style="height:20px"></tr>'+
	                	'<tr>'+    
	                		'<td><label class="layui-form-label left-label">使用地点</label></td>'+
	                		'<td><input type="text" name="useLocation" id="useLocation" value="'+data.useLocation+'" autocomplete="off" class="layui-input" style="width:150px"></td>'+
	                    	'<td><label class="layui-form-label left-label">设备巡检</label></td>'+
	                    	'<td><input type="button" value="具体项和内容" class="layui-input" style="width:150px" onclick="javascript:lookupItem01()"></td>'+
	                	'<tr>'+
	                	'<tr style="height:20px"></tr>'+
	                	'<tr>'+    
	                		'<td><input type="hidden" id="checkItemDetailIDArr" name="checkItemDetailIDArr"></td>'+
	            		'<tr>'+
	            		'<tr style="height:20px"></tr>'+
	            		'<tr>'+    
	            			'<td><label class="layui-form-label left-label">巡检人</label></td>'+
	            			'<td><input type="text" name="checkMan" id="checkMan" value="'+data.checkMan+'" autocomplete="off" class="layui-input" style="width:150px"></td>'+
	                		'<td><label class="layui-form-label left-label">巡检时间</label></td>'+
	                		'<td><input type="text" name="submitTime" id="submitTime1" value="'+data.submitTime+'" autocomplete="off" class="layui-input" style="width:150px"></td>'+
	            		'<tr>'+
	            		'<tr style="height:20px"></tr>'+
	            		'<tr>'+    
	            			'<td><label class="layui-form-label left-label">维修维护记录内容</label></td>'+
	            			'<td><textarea type="text" name="remark01" id="remark01" value="'+data.remark01+'" autocomplete="off" class="layui-textarea" style="width:150px;"></textarea></td>'+
	            			'<td></td>'+
	            			'<td></td>'+
	            		'<tr>'+
	            		'<tr style="height:20px"></tr>'+
	            		'<tr align="center">'+    
	        				'<td colspan="2"><button class="layui-btn layui-btn-blue" lay-submit lay-filter="editForm" style="margin-left:160px; margin-bottom: 20px">立即提交</button></td>'+
	        				'<td colspan="2">&emsp;&emsp;&emsp;&emsp;<button type="reset" class="layui-btn layui-btn-primary" style="margin-bottom: 20px">重置</button></td>'+
	        			'<tr>'+
	                  '</table>'+
                    '</form>'
                    ,success: function(){
                        //巡检时间
                        laydate.render({
                            elem: '#submitTime1',
                            type: 'datetime'
                        });
                      	//下拉查找所有设备
                        $.ajax({
    		  	            type: 'POST',
    		  	            url: '${pageContext.request.contextPath}/device/queryAllDeviceList.do',
    		  	            dataType: 'json',
    		  	            async: false,
    		  	            success: function (data){
    		  	                for (var i = 0; i < data.length; i++) {
    		  	                    $("#deviceNo").append("<option value='"+ data[i].deviceNo +"'>"+ data[i].deviceNo +"</option>");
    		  	                }
    		  	            }
    		  	        });
                      	//下拉框查找所有部门
    					$.ajax({
    			            type: 'POST',
    			            url: '${pageContext.request.contextPath}/device/queryAllDeptList.do',
    			            dataType: 'json',
    			            async: false,
    			            success: function (data){
    			                for (var i = 0; i < data.length; i++) {
    			                    $("#useDept1").append("<option value='"+ data[i].name +"'>"+ data[i].name +"</option>");
    			                }
    			            }
    			        });
                        //初始化radio、select等元素
                        form.render();
                    }
                });
            }
        });

        /*
	        $("#addFormID").hide();
	        $("#dv01").show();
	        $("#dv02").show();
	        $("#dv03").hide();
        */

        /**
         * 通用表单提交(AJAX方式)(新增)
         */
        form.on('submit(addForm)', function (data) {
            var sub = JSON.stringify(data.field);
            var temp1 = JSON.parse(sub);
            temp1['remark02'] = JSON.stringify(temp);
            var sub1 = JSON.stringify(temp1);
            $.ajax({
                url : '${pageContext.request.contextPath}/deviceAlarm/addCheckRecord.do',
                data: sub1,
                cache : false,
                type : "post",
                contentType: "application/json; charset=utf-8",
                beforeSend: function() {
                    layer.msg(JSON.stringify(temp));
                    //console.log(JSON.stringify(temp));
                },
            }).done(
                function(res) {
                    if (res > 0) {
                        toastrStyle();
                        toastr.success('添加成功！');
                        setTimeout(function(){
                            location.reload();
                        },1000);
                    }
                }
            ).fail(
                function(res) {
                    toastrStyle();
                    toastr.error('添加失败！');
                    setTimeout(function(){
                        location.reload();
                    },1000);
                }
            )
            return false;
        });

        //巡检时间
        laydate.render({
            elem: '#submitTime',
            type: 'datetime'
        });

        /**
         * 新增表单校验
         */
        form.verify({
            //value：表单的值item：表单的DOM对象
            deviceName: function(value, item){
                if(value == ''){
                    return '设备名称字段不能为空';
                }
            }/* ,
            deviceVersion: function(value, item){
                if(value == ''){
                    return '型号字段不能为空';
                }
            } */,
            deviceNo: function(value, item){
                if(value == ''){
                    return '设备编号字段不能为空';
                }
            }/* ,
            useDept: function(value, item){
                if(value == ''){
                    return '使用部门字段不能为空';
                }
            },
            useLocation: function(value, item){
                if(value == ''){
                    return '使用地点字段不能为空';
                }
            },
            checkMan: function(value, item){
                if(value == ''){
                    return '巡检人字段不能为空';
                }
            },
            submitTime: function(value, item){
                if(value == ''){
                    return '巡检时间字段不能为空';
                }
            } */
        });
        
      	//查找带回
        form.on('select(displayInfo)', function(data){
        	$.ajax({
                type: 'POST',
                url: '${pageContext.request.contextPath}/device/queryDeviceInfoByNo.do',
                data: {deviceNo:$('#deviceNo').val()},
                /* dataType: 'json', */
                /* async: false, */
                success: function (data){
                	var device = eval('(' +data+ ')');
                	$('#deviceName').val(device.deviceName);
                	$('#deviceVersion').val(device.deviceVersion);
                }
            });
        });
    });

    var temp = {};
    //具体项和内容的弹框(form表单的第一次链接)
    function lookupItem01(){
        layer.open({
            type: 1 					//Page层类型
            ,area: ['550px', '450px']   //宽  高
            ,title: '具体项和内容'
            ,shade: 0.6 				//遮罩透明度
            ,maxmin: true			    //允许全屏最小化
            ,anim: 1 					//0-6的动画形式，-1不开启
            /* ,content: $("#lookupTable2") */
            ,content: '<table class="layui-hide" id="lookupTable2" lay-filter="lookupTable2"></table>'
            ,success: function(){
                layui.use(['table'], function(){
                    var table = layui.table;
                    table.render({
                        elem: '#lookupTable2'
                        ,url:'${pageContext.request.contextPath }/deviceAlarm/queryCheckItem.do'
                        /* ,toolbar: '#toolbar' */
                        ,title: '具体项和内容'
                        ,height: 600
                        ,id :'contenttable'
                        ,limits:[10,20,30]
                        ,cols: [[
                            /* {type: 'checkbox', fixed: 'left'}, */
                            {field:'id', title:'ID', sort: true, type:'numbers'},
                            {field:'checkItemName', title:'维护维修巡检项名称'},
                            {field:'op1', title:'维护维修巡检项详细', templet:function (rowData){
                                    return "<a href='javascript:void(0)' style='color:#4D61B3' onclick='checkItemNameDetail(\""+rowData.id+"\")'>"+'查看详细'+"</a>";
                                }},
                            /*{unresize: true, title:'操作', toolbar: '#rowToolbar'}*/
                        ]]
                        ,page: false
                    });
                    /* var checkItemIdArr = new Array();
                  	//监听表格复选框选择
                    table.on('checkbox(lookupTable2)', function(obj){
                    	//如果被选中
                        if(obj.checked==true){
                        	checkItemIdArr.push(obj.data.id);
                        	//alert(checkItemIdArr.length)
                        }
                    }); */
                });
            }
        });
    }

    //JSON
    //维护维修项详细(第三次弹框)
    function checkItemNameDetail(cdId){
        layer.open({
            type: 1 					//Page层类型
            ,area: ['500px', '450px']   //宽  高
            ,title: '维护维修项详细'
            ,shade: 0.6 				//遮罩透明度
            ,maxmin: true 			    //允许全屏最小化
            ,anim: 1 					//0-6的动画形式，-1不开启
            /*,content: $("#lookupTable2") */
            //,content: '<table class="layui-table" id="lookupTable1" lay-filter="lookupTable11"></table>'+
            //          '<button class="layui-btn layui-btn-blue" data-type="getCheckData" style="width:300px; margin-left:100px; margin-top:10px; margin-bottom:10px;">确认</button>'
            ,content: '<table id="demo" lay-filter="test"></table>'+
                '<button id="qwe" class="layui-btn layui-btn-blue" data-type="getCheckData" style="width:300px; margin-left:100px; margin-top:10px; margin-bottom:10px;">确认</button>'
            ,success: function(){
                /* $("#addFormID").hide(); */
                //第三次弹框(渲染最后一个form)
                layui.use(['table'], function(){
                    var table11 = layui.table;
                    table11.render({
                        elem:'#demo'
                        ,url:'${pageContext.request.contextPath }/deviceAlarm/queryCheckItemDetailById.do?cdId='+cdId
                        /*,where:{dId:thisRowId.id}*/
                        /*,toolbar: '#toolbar'*/
                        ,title: '维护维修项详细'
                        ,id :'contenttable'
                        ,limits:[10,20,30]
                        ,cols: [[
                            {type: 'checkbox', fixed: 'left'},
                            {field:'id', title:'ID', fixed: 'left', unresize: true, sort: true, type:'numbers'},
                            {field:'checkItemDetailName', title:'维护维修巡检项详细'}
                            /*{unresize: true, title:'操作', toolbar: '#rowToolbar2', align: 'center'}*/
                        ]]
                        ,page: false
                    });
                    //将选中行的ID放入隐藏域(单个值)
                    /* ———————————————————————————————————————————————————— */
                    var key = cdId;
                    //$("#checkItemIDArr").val(cdId);
                    //map[key] = new Set();
                    //var set = new Set();
                    //map.put(key, set);
                    //监听表格复选框选择
                    /* table.on('checkbox(lookupTable1)', function(obj){
                    	//如果被选中
                        if(obj.checked == true){
                        	map.get(key).add(obj.data.id);
                        	//map[key].add(obj.data.id);
                        	//alert(checkItemDetailIdArr.length);
                        	//map.put(key);
                        }
                    }); */
                    var ids;
                    var $ = layui.$, active = {
                        getCheckData: function(){ //获取选中数据
                            var checkStatus = table11.checkStatus('contenttable'),
                                data = checkStatus.data;
                            ids = new Array();
                            for (var i in data) {
                                ids.push(data[i].id);
                            }
                            //layer.alert(JSON.stringify(data));
                            temp[cdId] = ids;
                            console.log(temp);
                        }
                    };

                    $('#qwe').on('click', function() {
                        var type = $(this).data('type');
                        active[type] ? active[type].call(this) : '';
                        layer.close(layer.index);
                    });
                    //将选中行的详细ID放入隐藏域(数组)
                    //$("#checkItemDetailIDArr").val(map);
                    //console.log(ids);
                    /* ———————————————————————————————————————————————————— */
                });
            }
        });
    }

    //提示框样式
    function toastrStyle() {
        toastr.options = {
            "closeButton": false,
            "debug": false,
            "newestOnTop": false,
            "progressBar": false,
            "positionClass": "toast-top-center",
            "preventDuplicates": false,
            "onclick": null,
            "showDuration": "5000",
            "hideDuration": "1000",
            "timeOut&quot": "100000",
            "extendedTimeOut": "0",
            "showEasing": "swing",
            "hideEasing": "linear",
            "showMethod": "fadeIn",
            "hideMethod": "fadeOut"
        };
    }

    //关闭当前弹出层
    function closeThieWindow(){
        layer.close(layer.index);
    }

    //列表页面巡检项详细
    function checkItemNameDetail2(thisRowId){
        $("#preRowId").val(thisRowId);
        layer.open({
            type: 1 					//Page层类型
            ,area: ['550px', '450px']   //宽  高
            ,title: '具体项和内容'
            ,shade: 0.6 				//遮罩透明度
            ,maxmin: true			    //允许全屏最小化
            ,anim: 1 					//0-6的动画形式，-1不开启
            /*,content: $("#lookupTable3") */
            ,content: '<table class="layui-hide" id="lookupTable3" lay-filter="lookupTable3"></table>'
            ,success: function(){
                layui.use(['table'], function(){
                    var table = layui.table;
                    table.render({
                        elem: '#lookupTable3'
                        ,url:'${pageContext.request.contextPath }/deviceAlarm/queryCheckItemById.do?id='+thisRowId
                        /*,where: {'preId':12}*/
                        /*,toolbar: '#toolbar'*/
                        ,title: '具体项和内容'
                        ,height: 600
                        ,id :'contenttable'
                        ,limits:[10,20,30]
                        ,cols: [[
                            {field:'id', title:'ID', sort: true, type:'numbers'},
                            {field:'checkItemName', title:'维护维修巡检项名称'},
                            {field:'op1', title:'维护维修巡检项详细', templet:function (rowData){
                                return "<a href='javascript:void(0)' style='color:#4D61B3' onclick='checkItemNameDetail3(\""+rowData.id+"\")'>"+'查看详细'+"</a>";
                            }},
                        ]]
                        ,page: false
                    });
                    /* var checkItemIdArr = new Array();
                  	//监听表格复选框选择
                    table.on('checkbox(lookupTable2)', function(obj){
                    	//如果被选中
                        if(obj.checked==true){
                        	checkItemIdArr.push(obj.data.id);
                        	//alert(checkItemIdArr.length)
                        }
                    }); */
                });
            }
        });
    }

    //展示页面的最高级别的详细查看
    function checkItemNameDetail3(cdId){
        //$("#preRowId").val()上一行数据的ID
        //thisRowId当前行的ID
        //alert(thisRowId + "," + $("#preRowId").val());
        layer.open({
            type: 1 					//Page层类型
            ,area: ['500px', '450px']   //宽  高
            ,title: '维护维修项详细'
            ,shade: 0.6 				//遮罩透明度
            ,maxmin: true 			    //允许全屏最小化
            ,anim: 1 					//0-6的动画形式，-1不开启
            ,content: '<table id="demo" lay-filter="test"></table>'
            ,success: function(){
                /*$("#addFormID").hide();*/
                //第三次弹框(渲染最后一个form)
                layui.use(['table'], function(){
                    var table11 = layui.table;
                    table11.render({
                        elem:'#demo'
                        ,url:'${pageContext.request.contextPath }/deviceAlarm/queryCheckItemDetailById3.do?cdId='+cdId
                        ,where:{preRowId : $("#preRowId").val()}
                        ,title: '维护维修项详细'
                        ,id:'contenttable'
                        ,limits:[10,20,30]
                        ,cols: [[
                            /* {type: 'checkbox', fixed: 'left'}, */
                            {field:'id', title:'ID', fixed: 'left', unresize: true, sort: true, type:'numbers'},
                            {field:'checkItemDetailName', title:'维护维修巡检项详细'}
                        ]]
                        ,page: false
                    });
                });
            }
        });
    }
</script>

<!-- 声明Map集合 -->
<script type="text/javascript">
    function Map() {
        this.elements = new Array();

        //获取MAP元素个数
        this.size = function() {
            return this.elements.length;
        }

        //判断MAP是否为空
        this.isEmpty = function() {
            return(this.elements.length < 1);
        }

        //删除MAP所有元素
        this.clear = function() {
            this.elements = new Array();
        }

        //向MAP中增加元素（key, value)
        this.put = function(_key, _value) {
            this.elements.push( {
                key : _key,
                value : _value
            });
        }

        //删除指定KEY的元素，成功返回True，失败返回False
        this.remove = function(_key) {
            var bln = false;
            try{
                for(i = 0; i < this.elements.length; i++) {
                    if(this.elements[i].key == _key) {
                        this.elements.splice(i, 1);
                        return true;
                    }
                }
            } catch(e) {
                bln = false;
            }
            return bln;
        }

        //获取指定KEY的元素值VALUE，失败返回NULL
        this.get = function(_key) {
            try{
                for(i = 0; i < this.elements.length; i++) {
                    if(this.elements[i].key == _key) {
                        return this.elements[i].value;
                    }
                }
            } catch(e) {
                return null;
            }
        }

        //获取指定索引的元素（使用element.key，element.value获取KEY和VALUE），失败返回NULL
        this.element = function(_index) {
            if(_index < 0 || _index >= this.elements.length) {
                return null;
            }
            return this.elements[_index];
        }

        //判断MAP中是否含有指定KEY的元素
        this.containsKey = function(_key) {
            varbln = false;
            try{
                for(i = 0; i < this.elements.length; i++) {
                    if(this.elements[i].key == _key) {
                        bln = true;
                    }
                }
            } catch(e) {
                bln = false;
            }
            return bln;
        }

        //判断MAP中是否含有指定VALUE的元素
        this.containsValue = function(_value) {
            var bln = false;
            try{
                for(i = 0; i < this.elements.length; i++) {
                    if(this.elements[i].value == _value) {
                        bln = true;
                    }
                }
            } catch(e) {
                bln = false;
            }
            return bln;
        }

        //获取MAP中所有VALUE的数组（ARRAY）
        this.values = function() {
            var arr = new Array();
            for(i = 0; i < this.elements.length; i++) {
                arr.push(this.elements[i].value);
            }
            return arr;
        }

        //获取MAP中所有KEY的数组（ARRAY）
        this.keys = function() {
            var arr = new Array();
            for(i = 0; i < this.elements.length; i++) {
                arr.push(this.elements[i].key);
            }
            return arr;
        }
    }

    /*
        var map = new Map();
        map.put("key1", "value1");
        map.put("key2", "value2");
        map.put("key3", "value3");

        //var val = map.get("key1");
        //var val = map.containsKey("key1");
        //var val = map.element(2).value;

        var arr=map.keys();
        for(var i=0;i<arr.length;i++){
            alert(map.get(arr[i]));
        }
    */
    //alert(val);
</script>
</body>
</html>